﻿using System;
using System.Collections;
using System.Runtime.Serialization;
using System.Web;

namespace NWebMock
{
    public class HttpModuleCollectionWrapper : IHttpModuleCollection
    {
        #region Constructors

        public HttpModuleCollectionWrapper(HttpModuleCollection modules)
        {
            if (modules == null)
            {
                throw new ArgumentNullException("modules");
            }

            this.innerModules = modules;
        }

        #endregion

        #region Fields

        private HttpModuleCollection innerModules = null;

        #endregion

        #region Properties

        public string[] AllKeys { get { return this.innerModules.AllKeys; } }

        public int Count { get { return this.innerModules.Count; } }

        public IHttpModule this[int index] { get { return this.innerModules[index]; } }

        public IHttpModule this[string name] { get { return this.innerModules[name]; } }

        public ICollection Keys { get { return this.innerModules.Keys; } }

        #endregion

        #region Methods

        public void CopyTo(Array dest, int index)
        {
            this.innerModules.CopyTo(dest, index);
        }

        public IHttpModule Get(int index)
        {
            return this.innerModules.Get(index);
        }

        public IHttpModule Get(string name)
        {
            return this.innerModules.Get(name);
        }

        public IEnumerator GetEnumerator()
        {
            return this.innerModules.GetEnumerator();
        }

        public string GetKey(int index)
        {
            return this.innerModules.GetKey(index);
        }

        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            this.innerModules.GetObjectData(info, context);
        }

        public void OnDeserialization(object sender)
        {
            this.innerModules.OnDeserialization(sender);
        }

        #endregion

        #region ICollection Members

        bool ICollection.IsSynchronized { get { return ((ICollection)this.innerModules).IsSynchronized; } }

        object ICollection.SyncRoot { get { return ((ICollection)this.innerModules).SyncRoot; } }

        #endregion
    }
}
